import os

from celery import Celery

# 定时任务需要加上 -B
# celery -A celery_task worker -l info

REDIS_HOST = os.environ.get('REDIS_HOST', "127.0.0.1")
REDIS_PORT = os.environ.get('REDIS_PORT', "6379")

app = Celery('app',
             broker=f"redis://{REDIS_HOST}:{REDIS_PORT}/2",
             backend=f"redis://{REDIS_HOST}:{REDIS_PORT}/2",
             include=['app.tasks'])

app.config_from_object('celery_config')

if __name__ == '__main__':
    app.start()
